// $Id: PlayerDB.h 112 2007-11-15 20:16:27Z wimleers $


/**
 * PlayerDB class header file.
 *
 * @file PlayerDB.h
 * @author Wim Leers
 */


#ifndef PLAYERDB_H
#define PLAYERDB_H

#include <map>
#include <string>
using namespace std;
#include "Player.h"
#include "FileIO.h"

struct playerNameCompare {
  bool operator()(string name1, string name2) const {
	  return name1.compare(name2) < 0;
  }
};

class PlayerDB {
	public:
		PlayerDB(void) { Load(); }
		~PlayerDB(void);
		Player * GetPlayer(string name);
		void AddPlayer(Player * player);
		void Erase(void);
		void Save(void);
		int Size(void) { return m_db.size(); }
		string GetHighScores(void);
	private:
		map<string, Player *, playerNameCompare> m_db;
		static const string FILENAME;
		FILEIO_TABLE m_table;
		FileIO m_fileIO;
		void Load(void);
};

#endif
